//
//  ViewController.m
//  personalBlock
//
//  Created by izhifei-Devon on 2017/6/7.
//  Copyright © 2017年 izhifei-Devon. All rights reserved.
//

#import "ViewController.h"
#import "BlockViewController.h"

@interface ViewController ()

@property(nonatomic,strong)UILabel * myBlock;

@end

@implementation ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    _myBlock = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 80, 30)];
    
    _myBlock.text = @"123";
    
    [self.view addSubview:_myBlock];
    
    dispatch_queue_t queue = dispatch_queue_create("myblock.testQueue", DISPATCH_QUEUE_SERIAL);
    NSLog(@"之前1 - %@",[NSThread currentThread]);
    dispatch_async(queue, ^{
        NSLog(@"sync之前2 - %@",[NSThread currentThread]);
        dispatch_sync(queue, ^{
            NSLog(@"sync3 - %@",[NSThread currentThread]);
        });
        NSLog(@"sync之后4 - %@",[NSThread currentThread]);
    });
    
    NSLog(@"之后5 -%@",[NSThread currentThread]);
    
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    BlockViewController * view = [[BlockViewController alloc]init];
    
    view.changeSelf = ^(UIColor * col, NSString * str) {
        
        self.view.backgroundColor = col;
        
        _myBlock.text = str;

    };
    
    [self presentViewController:view animated:YES completion:nil];
}


@end
